<?php

/**

@version 1.0: mod_ltc_weather

Author: Shape 5 - Professional Template Community

Free extension available for download at www.shape5.com

*/





// no direct access

defined('_JEXEC') or die('Restricted access');

global $mosConfig_offset, $mosConfig_live_site, $mainframe;

$text  = $params->get( 'textif');

$zipcodes  = $params->get( 'zipcodes');

$scale  = $params->get( 'scale');

if ($zipcodes) {

    $zipcode_city = preg_split('/[\n,]|<br \/>/', $zipcodes);

	}else {

		$zipcode_city = "VMXX0006:Hà Nội";

	}

	

$zipcode=array();

$cityname=array();

for ($i = 0; $i < count($zipcode_city); $i ++)

	{	

		$zipcode[$i]=substr($zipcode_city[$i],0,8);

		$cityname[$i]=substr($zipcode_city[$i],9);

	}







$LiveSite = JURI::base();

?>

	

<?php

$br = strtolower($_SERVER['HTTP_USER_AGENT']); // what browser.

if(ereg("msie 6", $br)) {

$iss_ie6 = "yes";

} 

else {

$iss_ie6 = "no";

}

?>





		



<script type="text/javascript">//<![CDATA[

    document.write('<link href="<?php echo $LiveSite?>modules/mod_ltc_weather/ltc_weather/style.css" rel="stylesheet" type="text/css" media="screen" />');

//]]></script>	



<?php

	

	error_reporting(0); 

	

	include('weather.class.php');

	$ltc_head="";

	$ltc_select="";

	$ltc_body="";

	$ltc_bottom="";

	

	if ($iss_ie6 == "yes") {

			$ltc_head.="<div><div><div class=\"ltc_weather_middle\"><div class=\"ltc_weather_tl\"></div><div class=\"ltc_weather_tr\"></div></div><div	 style=\"clear:both;margin-top:-6px;\"></div>";

			} else {

			$ltc_head.= "<div><div><div class=\"ltc_weather_middle\"><div class=\"ltc_weather_tl\"></div><div class=\"ltc_weather_tr\"></div></div><div style=\"clear:both;\"></div>";		

			}	

			

			$ltc_head.= "<div class=\"ltc_weather_brep\"><div class=\"ltc_weather_rl\"><div class=\"ltc_weather_rr\">";

			$ltc_select.="<div align=\"center\"><select id=\"SelectWeather\" style=\"border-top:0px; border-left:0px;  border-bottom: solid 1px #2982D6;  font-family:'Times New Roman'; font-size:15px; font-weight:bolder; color:#1D2A5E;  width:90%\" onchange=\"ShowCity(this.value);\" disabled>";

			

			

	

	

	for ($i = 0; $i < count($zipcode); $i ++)

	{	

			$ltc_select.= "<option style=\"border-bottom:solid 1px #2982D6;\" value=\"".$zipcode[$i]."\">".$cityname[$i]."</option>";					

	}

	$ltc_select.= "</select></div>";

	

	$ltc_body.= "<div align=\"center\" style=\"padding-top:0px\"><div id=\"LoadingWeather\" align=\"center\" style=\"padding-top:15px;\"><img border=\"0\" src='".$LiveSite."modules/mod_ltc_weather/ltc_weather/loading.gif' /><br/><font color=\"#cccccc\" size=\"1\">NguoiYenThanh.Com <br/> Đang Tải Dữ Liệu</font></div>";

	$ltc_body.=  "<div id=\"WeatherBox\" align=\"center\" style=\"display:none\"><iframe  id=\"ltc_weather_embed\" scrolling=\"no\" frameborder=\"0\" \ height=\"100\" width=\"94%\" src=\"".$LiveSite."/modules/mod_ltc_weather/mod_ltc_weather_embed.php?zip=".$zipcode[0]."&scale=".$scale."\" onload=\"LoadBoxOk();\"></iframe></div></div>";

	

	

	

	$ltc_bottom.= "</div></div></div></div></div>";				

	

	echo $ltc_head.$ltc_select;

	echo $ltc_body;

	echo $ltc_bottom;

	

	echo "<script language=\"javascript\" type=\"text/javascript\">\n";

	echo "function ShowCity(z)\n";

	echo "{\n";	

	echo "document.getElementById('ltc_weather_embed').src='".$LiveSite."/modules/mod_ltc_weather/mod_ltc_weather_embed.php?zip='+z+'&scale=".$scale."';\n";

	echo "document.getElementById('LoadingWeather').style.display='block';\n";

	echo "document.getElementById('WeatherBox').style.display='none';\n";

	echo "document.getElementById('SelectWeather').disabled=true;\n";

	echo "}\n";

	echo "function LoadBoxOk()\n";

	echo "{\n";	

	echo "document.getElementById('LoadingWeather').style.display='none';\n";

	echo "document.getElementById('WeatherBox').style.display='block';\n";

	echo "document.getElementById('SelectWeather').disabled=false;\n";

	echo "}\n";

	

	echo "</script>\n";

?>





